package com.qfedu.provider.controller;

import com.qfedu.config.SystemConfig;
import com.qfedu.parm.CommentAdd;
import com.qfedu.provider.service.DbCommentService;
import com.qfedu.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author Administrator
 * @date 2024/11/25 下午3:47
 */
@Slf4j
@RestController
@RequestMapping("/server/comment")
@Tag(name = "评论管理")
public class CommentController {

    @Resource
    private DbCommentService dbCommentService;

    @Operation(summary = "添加评论")
    @PostMapping("add")
    public R add(@RequestBody CommentAdd commentAdd, HttpServletRequest request) {
        return dbCommentService.add(commentAdd, request.getHeader(SystemConfig.TOKEN));
    }

    @Operation(summary = "删除评论")
    @PostMapping("delete")
    public R delete(@RequestParam("commentId") Integer commentId, HttpServletRequest request) {
        return dbCommentService.delete( commentId,request.getHeader(SystemConfig.TOKEN));
    }
}
